<template>
  <div>
    <!-- 头部栏 -->
    <van-nav-bar title="收货地址"
                 left-arrow
                 @click-left="$router.go(-1)" />
    <!-- 地址列表 -->
    <van-address-list v-model="chosenAddressId"
                      :list="addrlist"
                      default-tag-text="默认"
                      @add="$router.push('/editaddress')"
                      @edit="onEdit" />
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'addressPage',
  data () {
    return {
      chosenAddressId: 17290
    }
  },
  created () {
    this.getAddress()

  },
  methods: {
    getAddress () {
      this.$store.dispatch('address/getAddress')
    },
    onEdit (item) {
      console.log(item);
      this.$router.push({
        path: '/editaddress',
        query: {
          addressId: item.id
        }
      })
    }
  },
  computed: {
    ...mapState('address', ['addrlist'])
  }
}
</script>

<style>
</style>